<template>
  <hips-view sub-header-fixed>
    <hips-nav-bar
      slot="header"
      title="联系人类"
      :back-button="{
        showLeftArrow: true,
      }"
      @nav-bar-back-click="$router.back()"
    />
    <demo-block title="getEnterpriseContact">
      <hips-button
        @click="getEnterpriseContactFuc"
      >
        选择应用内部企业联系人
      </hips-button>
    </demo-block>

    <demo-block title="getMobileContact">
      <hips-button @click="getMobileContactFuc">
        获取手机联系人
      </hips-button>
    </demo-block>

    <demo-block title="filterMobileContact">
      <hips-button
        @click="filterMobileContactFuc"
      >
        筛选获取手机联系人
      </hips-button>
    </demo-block>

    <demo-block title="startSingleConversation">
      <hips-button
        @click="startSingleConversationFuc"
      >
        在应用内部打开联系人建立会话
      </hips-button>
    </demo-block>

    <demo-block title="saveMobileContact">
      <hips-button
        @click="saveMobileContactFuc"
      >
        打开联系人编辑页面保存联系人
      </hips-button>
    </demo-block>
  </hips-view>
</template>

<script>
import BasicView from '@/mixin/basic-view';
import { Button } from '@hips/vue-ui';

import { Contact } from '@hips/plugin-vue-jssdk';

const {
  getEnterpriseContact,
  getMobileContact,
  filterMobileContact,
  startSingleConversation,
  saveMobileContact,
} = Contact;

export default {
  components: {
    [Button.name]: Button,
  },
  mixins: [ BasicView ],
  data() {
    return {};
  },
  methods: {
    getEnterpriseContactFuc() {
      getEnterpriseContact({
        limitNum: 2,
      })
        .then((res) => {
          console.log('res = ', res);
        })
        .catch((err) => {
          console.log('err = ', err);
        });
    },
    getMobileContactFuc() {
      getMobileContact()
        .then((res) => {
          console.log('res = ', res);
        })
        .catch((err) => {
          console.log('err = ', err);
        });
    },
    filterMobileContactFuc() {
      filterMobileContact({
        filter: 'John',
      })
        .then((res) => {
          console.log('res = ', res);
        })
        .catch((err) => {
          console.log('err = ', err);
        });
    },
    startSingleConversationFuc() {
      startSingleConversation({ targetId: '7949' })
    },
    saveMobileContactFuc() {
      saveMobileContact({
        name: '三',
        familyName: '张',
        phone: 13812631998,
      })

    },
  },
};
</script>

<style lang="stylus"></style>
